﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectNocturnalFool
{
    class GenderPanel : PanelControl
    {
        List<GenderButton> btns = new List<GenderButton>();

        public override int width
        {
            get
            {
                return base.width;
            }
            set
            {
                base.width = value;
                spaceButtons();
            }
        }

        public override void LoadContent()
        {
            base.LoadContent();
            List<Gender> genderList = CharacterLoader.loadGender(GameLogic.Instance.gameCharacterSession.editCharacter);
            GenderButton addBtn;
            int[] space = Util.spaceEvenX(2, Constants.ButtonWidth, VirtualScreen.Instance.VirtualWidth / 2);

            for (int i = 0; i < genderList.Count; i++)
            {
                addBtn = new GenderButton();
                addBtn.LoadContent();
                addBtn.gender = genderList[i];
                addBtn.style = Button_Style.Short;
                controls.Add(addBtn);
                btns.Add(addBtn);
            }

            ButtonControl btn = new ButtonControl();
            btn.LoadContent();
            btn.yAnchor = VerticleAnchor.Bottom;
            btn.xAnchor = HorizontalAnchor.Middle;
            btn.type = Button_Type.GenderCancel;
            btn.y = (y + height) - (btn.height + Constants.ControlSmallOffsets);
            controls.Add(btn);

        }

        private void spaceButtons()
        {
            if (btns.Count > 0)
            {
                int[] spacingX = Util.spaceEvenX(2, btns[0].width, width);

                for (int i = 0; i < btns.Count; i++)
                {
                        btns[i].x = x + spacingX[i % 2];
                }
            }
        }


    }
}
